package main;

import java.util.ArrayList;

public class Subject {
	private String data;
	private ArrayList<Observers> observersList;
	public Subject(String s ,ArrayList<Observers> observersList) {
		this.data = s;
		this.observersList = observersList;
		this.notifyAllObservers();
	}
	public String getValue() {
		return data;
	}
	public void setValue( String s ) {
		this.data = s;
		this.notifyAllObservers();
	}
	public void attach( Observers obj ) {
		this.observersList.add(obj);
	}
	public void notifyAllObservers() {
		for(int i = 0; i < this.observersList.size(); i++) {
			this.observersList.get(i).react(this.data);
		}
	}
}
